//
// Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
//
// GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
//  Author: Shawn.Tan
//  Date : 2025.10.28
//
//  History : Initial Version 2025.10.28
//
//
#include "SymbolManager.h"

#include "Log.h"

using namespace std;

namespace Green
{
  
  Symbol::Symbol(const std::string& name)
    : mName(name), mAddress(0), mSet(false)
  {

  }

  SymbolManager::SymbolManager(EMemBankType bankType)
    : mBankType(bankType), mSymbolMap()
  {

  }

  SymbolManager::~SymbolManager()
  {
    for (auto map_item : mSymbolMap) {
      delete map_item.second;
    }
  }

  void SymbolManager::AddSymbol(const std::string& rName, uint64 address)
  {
    if (mSymbolMap.find(rName) != mSymbolMap.end()) {
      LOG(fail) << "Symbol already exist: " << rName << endl;
      FAIL("adding-duplicated-symbol");
    }

    Symbol* new_symbol = new Symbol(rName);
    new_symbol->SetAddress(address);
    mSymbolMap[rName] = new_symbol;
  }
  
}
